<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <meta name = "format-detection" content = "telephone=no">
    <title>地址列表</title>
    <link rel="stylesheet" href="/Public/Home/css/address.css">
    <!--不识别数字为手机-->
<meta name="format-detection" content="telephone=no, email=no"/>
<!--通用js-->
<?php if(isset($signPackage) && !empty($signPackage)){ ?>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js?v=201704270010"></script>
<?php } ?>
<script type="text/javascript" src="/Public/Home/js/require.js"></script>
<script type="text/javascript" src="/Public/Home/js/baseLoading.js?v=201705240001"></script>
<script src="/Public/Home/js/jquery.min.js" ></script>
<script src="/Public/Home/js/pincode-input.js" ></script>
<script src="/Public/Home/js/parabola.js" ></script>
<script src="/Public/Home/js/lazyload/jquery.lazyload.min.js"></script>
<script type="text/javascript">
    _global.isLogin = !!"<?php echo $wx_member_id; ?>";
	var isWxShareDiy = typeof yc_share_diy === "undefined" ? false : yc_share_diy;
	var yc_wx_shareImgPath = "";
	<?php if(isset($weixin_logo) && !empty($weixin_logo)){ ?>
		yc_wx_shareImgPath = "/Uploads/<?php echo ($weixin_logo["image"]); ?>";
	<?php } ?>
    var yc_pass_arr = {'local_id':"<?php echo I('local_id',1);?>",'top_local_id':"<?php echo I('top_local_id',1);?>"};
	if(parseInt(yc_pass_arr["local_id"]) == 21){
		_global.isStopSell = true;
	}
    <?php if(isset($signPackage) && !empty($signPackage)){ ?>
        _global.isWeiXinLoad = true;
        var isEnableLocation = typeof yc_wx_location === "undefined" ? false : yc_wx_location;
        var yc_wx_options = {
            "enableLocation" : isEnableLocation,
            "refuseCallback" : function(){},
            "mapCallback" : function(){},
            "config" : {
                debug: false,
                appId: '<?php echo $signPackage["appId"];?>',
                timestamp: '<?php echo $signPackage["timestamp"];?>',
                nonceStr: '<?php echo $signPackage["nonceStr"];?>',
                signature: '<?php echo $signPackage["signature"];?>',
                jsApiList: [
                    'checkJsApi'
                ]
            }
        };
        var isInHeader = typeof yc_wx_useInHeader === "undefined" ? true : yc_wx_useInHeader;
        if(isInHeader){
            wxAutoConfig(yc_wx_options);
        }
    <?php } ?>
</script>
</head>
<body style="background:#e8eded;">

<style>
    .empty-box {
        text-align: center;
        height: 100%;
        padding-top: 2rem;
    }
    .empty-box img {
        width: 1.73rem;
        height: 2.92rem;
    }
    .empty-box p {
        font-size: .3rem;
        color: #5c6160;
        padding: 0 2rem;
    }
</style>

<?php if(empty($addList)): ?><div class="empty-box" >
    <img src="/Public/Home/images/iconEmpty.png" alt="">
    <p>请先添加收货地址</p>
</div><?php endif; ?>
<?php if(!empty($addList)): ?><div class="warp">
    <div class="address-list">
        <ul>
            <?php if(is_array($addList)): $i = 0; $__LIST__ = $addList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$addr): $mod = ($i % 2 );++$i;?><li class="addr-one-box">
                    <div class="top" style="padding-left: .1rem;" data-id="<?php echo ($addr["addr_id"]); ?>">
                       <!-- <a href="javascript:void(0);" class="choice <?php if($addr[def_addr] == 1 ): ?>active<?php endif; ?>"></a>-->
                        <p class="clearfix"><span class="fl"><?php echo ($addr["name"]); ?></span><span class="fr"><?php echo ($addr["mobile"]); ?></span></p>
                        <p class="text-hide"><?php if($addr["def_addr"] == 1 ): ?><label>默认地址</label><?php endif; echo ($addr["area"]); echo ($addr["addr"]); ?></p>
                    </div>

                    <div class="bot">

                       <!-- <a>使用该地址 </a>-->

                        <a href="javascript:void(0);" onclick="window.location.href='<?php echo url('Address/addAddress');?>?addrId=<?php echo ($addr[addr_id]); ?>'" class="edit">编辑</a>
                        <a href="javascript:void(0);" onclick="delAddress(this, <?php echo ($addr[addr_id]); ?>)" class="delete">删除</a>
                    </div>
                </li><?php endforeach; endif; else: echo "" ;endif; ?>
        </ul>
    </div>
</div><?php endif; ?>
<div class="address-new"><a href="<?php echo url('Address/addressModify');?>" class="btn btn-block ">+新建地址</a></div>
<script type="text/javascript">
    var _isDeleting = false;
    function delAddress(o, addrId){
        if(_isDeleting){
            return;
        }
        _isDeleting = true;
        _global.promote.loadPopup("正在处理中...");
        $.ajax({
            type: "POST",
            url: "/Home/Address/deleteAddr",
            data: {"addrId" : addrId},
            dataType: "json",
            success: function (rs) {
                _global.promote.removeLoad();
                _global.promote.alertPopup(rs.msg);
                if(rs.status){
                    $(o).parents(".addr-one-box").remove();
                }
                _isDeleting = false;
            },
            error: function () {
                _global.promote.removeLoad();
                _global.promote.alertPopup('服务器异常，请稍后重试！');
                _isDeleting = false;
            }
        });
    }
	require(['addressList']);
</script>
</body>
</html>